<?php

defined('SYSPATH') OR die('No direct access allowed.');

class Controller_Users extends Controller_Initialize {

  public $secure_actions = array();


  public function action_index() {

    $this->template->navigation->active = 'users';

    $view = View::factory('templates/users/index')
      ->bind('users', $result)
      ->bind('pagination', $pagination);

    $users = ORM::factory('user');

    $total_items = $users->count_all();

    $pagination = new Pagination(array(
      'current_page' => array('source' => 'route', 'key' => 'page'),
      'total_items' => $total_items,
      'items_per_page'=> 6,
      'auto_hide' => true,
    ));


    $result = $users->limit($pagination->items_per_page)->offset($pagination->offset)->find_all();

    $this->template->content = $view;

  }

}